var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let that = this
    //获取手机高度
    this.setData({
      navH: app.globalData.navHeight,
      orderId: options.orderId,
      lipinka: options.lipinka
    })
    console.info(that.data.orderId);
    wx.request({
      url: app.globalData.url + 'getProductUserLikeList',
      data: {
        userId: wx.getStorageSync("userId"),
      },
      method: "POST",
      header: {
        "content-type": "application/x-www-form-urlencoded"
      },
      success: function (res) {
        for (var i = 0; i < res.data.data.length; i++) {
          if (res.data.data[i].promotionMsg !=undefined) {
            var arr = res.data.data[i].promotionMsg.split(",");
            res.data.data[i].arr = arr;
          } else {
            res.data.data[i].arr = [];
          }
          if (res.data.data[i].promotionType != undefined) {
            //先按照逗号分割字符串
            let arrycode = res.data.data[i].promotionType.split(",");
            //去重
            arrycode = Array.from(new Set(arrycode));
            //拼接正确的nextOperatorCode
            res.data.data[i].promotionType = arrycode = arrycode.toLocaleString();
            // var promotionType = res.data.data[i].promotionType.split(",");
            // res.data.data[i].promotionType = promotionType;
          } else {
            res.data.data[i].promotionType = [];
          }
        }
        
        that.setData({
          likeList: res.data.data
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    var that = this;
    wx.request({
      url: app.globalData.url + 'getOrderDetails',
      method: 'GET',
      data: {
        orderId: that.data.orderId
      },
      success: function (res) {
        that.setData({
          order:res.data.data
        })
      },
    });
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  toIndex: function () {
    wx.reLaunch({
      url: '/pages/mallPage/mallPage',
    })
  },

  toDetail: function () {
    var that = this;
    if (that.data.lipinka != undefined) {
      wx.navigateTo({
        url: '/pages/mentionCarDetials/mentionCarDetials?orderId=' + that.data.orderId,
      })
    } else {
      wx.navigateTo({
        url: '/pages/orderDetails/orderDetails?orderId=' + that.data.orderId,
      })
    }
    
  },

  navBack: function () {
    wx.navigateBack({
      delta: 3,
    })
  },
   /**
   * 跳转到产品详情
   */
  details: function(res) {
    var productid = res.currentTarget.dataset.productid;
    var type = res.currentTarget.dataset.type;
    wx.navigateTo({
      url: '/pages/productDetail/productDetail?productid=' + productid + '&type=' + type,
    })
   
  },
})